package cn.jbolt.ai.resource.function.controller;

import cn.jbolt.ai.resource.function.entity.AiFunctionResource;
import cn.jbolt.ai.resource.function.enums.SyncStrategy;
import cn.jbolt.ai.resource.function.service.AiFunctionResourceService;
import cn.jbolt.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * AI函数管理
 */
@Controller
@ResponseBody
@RequestMapping("/aiFunction")
@Tag(name = "AI函数管理Controller")
public class AiFunctionResourceController {

    @Autowired
    private AiFunctionResourceService functionService;

    @Operation(summary = "根据ID获取AI函数信息", description = "根据ID获取AI函数信息")
    @GetMapping("/getById/{id}")
    public Result getById(@PathVariable Long id) {
        return functionService.getFunctionById(id);
    }

    @Operation(summary = "获取所有AI函数信息", description = "获取所有AI函数信息")
    @GetMapping("/list")
    public Result listByPage(Integer page, Integer pageSize,
                          @RequestParam(required = false) String keywords,
                          @RequestParam(required = false) Integer type,
                          @RequestParam(required = false) Boolean enable) {
        return functionService.listByPage(page, pageSize, keywords,type,enable);
    }



    @Operation(summary = "修改AI函数的启用状态", description = "修改AI函数的启用状态")
    @GetMapping("/toggleEnable/{id}")
    public Result toggleEnable(@PathVariable Long id) {
        return functionService.toggleEnable(id);
    }


    @Operation(summary = "同步本地Function资源", description = "同步本地Function资源")
    @GetMapping("/syncNativeFunctions")
    public Result syncNativeFunctions(String strategyCode){
        return functionService.syncNativeFunctions(strategyCode);
    }

    @Operation(summary = "获取同步策略的list", description = "获取同步策略的list")
    @GetMapping("/syncStrategyList")
    public Result syncStrategyList(){
        return functionService.syncStrategyList();
    }


}

